package com.example.xuanke.controller;

import com.example.xuanke.pojo.Classes;
import com.example.xuanke.pojo.Result;
import com.example.xuanke.service.ClassesService;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/classes")
public class ClassesController {
    @Autowired
    private ClassesService classesService;


    @GetMapping
    private Result getAll(){
        List<Classes> classes = classesService.getAll();
        return Result.success("获取班级信息成功",classes);
    }

    @PostMapping
    private Result add(@RequestBody Classes classes){
        classesService.add(classes);
        return Result.success("添加班级信息成功",classes);
    }

    @PutMapping
    public Result update(@RequestBody Classes classes){
        classesService.update(classes);
        return Result.success("修改学生信息成功",classes);
    }

    @DeleteMapping
    public Result delete(Integer id){
        classesService.delete(id);
        return Result.success("删除学生信息成功",id);
    }
}
